package StringC;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-03-03
 * Time:11:03
 * Text：67. 二进制求和
 */
public class Text4 {
    public static String addBinary(String a, String b) {
        int num=0;
        int i=a.length()-1;
        int j=b.length()-1;

        StringBuffer str=new StringBuffer();
        while(i>=0 || j>=0 || num!=0){
            int sum=0;
            if(i>=0){
                sum+=a.charAt(i)-48;
                i--;
            }
            if(j>=0){
                sum+=b.charAt(j)-48;
                j--;
            }
            sum+=num;
            if(sum>=2) num=1;
            if(sum==2 || sum==0) str.append('0');
            if(sum==1 || sum==3) str.append('1');
            if(sum==1) num=0;
        }
        return str.reverse().toString();
    }
    public static void main(String[] args) {
        System.out.println(Math.pow(10,1));
        System.out.println(addBinary("11","1"));
        ;

    }
}
